package com.cloudspace.jindun.activity.locate;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.widget.ListView;
import android.widget.TextView;

import com.cloudspace.jindun.R;
import com.cloudspace.jindun.activity.CustomTitleBaseActivity;
import com.cloudspace.jindun.adapter.locate.LocateAreaPersonsAdapter;
import com.cloudspace.jindun.model.LocateArea;
import com.cloudspace.jindun.model.LocatePerson;

import java.util.List;

/**
 * Created by zengxianhua on 17/3/4.
 */

public class LocateAreaPersonsActivity extends CustomTitleBaseActivity{
    private ListView listView;
    private LocateAreaPersonsAdapter adapter;

    private List<LocatePerson> datas;

    private TextView text2;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_locate_statistics_person, true);
        getTitleBar().setSimpleMode(getResources().getString(R.string.person_statistics));

        adapter = new LocateAreaPersonsAdapter();
        listView = (ListView) findViewById(R.id.lv);
        listView.setAdapter(adapter);

        text2 = (TextView) findViewById(R.id.text2);

        if (getIntent() != null){
            LocateArea area = (LocateArea) getIntent().getSerializableExtra("area");
            departName = getIntent().getStringExtra("departName");

            if (!TextUtils.isEmpty(departName)){
                text2.setText(getResources().getString(R.string.department));
            }

            if (area != null){
                datas = area.perList;
                adapter.setDatas(datas);
                adapter.setDepartName(departName);
            }
        }
    }

    private String  departName;

    public static void  showActivity(Context context, LocateArea area, String  departName){
        Intent intent = new Intent(context, LocateAreaPersonsActivity.class);
        if (!(context instanceof Context)){
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        }

        intent.putExtra("departName", departName);
        intent.putExtra("area", area);
        context.startActivity(intent);
    }
}
